<template>
	<view class="login-container">
		<!-- 背景元素 -->
		<view class="login-bg">
			<view class="bg-circle circle-1"></view>
			<view class="bg-circle circle-2"></view>
		</view>
		
		<view class="login-header">
			<image class="logo-image" src="/static/logo.png" mode="scaleToFill"></image>
			<text class="app-name">AI-Leader</text>
			<text class="app-slogan">智能驱动，领航未来</text>
		</view>
		
		<view class="login-card">
			<!-- 登录方式切换选项卡 -->
			<view class="login-tabs">
				<view 
					class="tab-item" 
					:class="{ active: loginType === 'phone' }"
					@click="switchLoginType('phone')"
				>手机号登录</view>
				<view 
					class="tab-item" 
					:class="{ active: loginType === 'account' }"
					@click="switchLoginType('account')"
				>账号密码登录</view>
			</view>
			
			<!-- 手机号登录表单 -->
			<block v-if="loginType === 'phone'">
				<view class="form-item">
					<view class="input-wrapper">
						<text class="input-icon iconfont">&#xe678;</text>
						<input type="number" v-model="phone" placeholder="请输入手机号" maxlength="11" />
					</view>
				</view>
				
				<view class="form-item">
					<view class="input-wrapper code-wrapper">
						<text class="input-icon iconfont">&#xe63d;</text>
						<input type="number" v-model="code" placeholder="请输入验证码" maxlength="6" />
						<button class="code-btn" :disabled="counting || !isAgreed" @click="sendCode">
							{{counting ? `${counter}s` : '获取验证码'}}
						</button>
					</view>
				</view>
			</block>
			
			<!-- 账号密码登录表单 -->
			<block v-else>
				<view class="form-item">
					<view class="input-wrapper">
						<text class="input-icon iconfont">&#xe678;</text>
						<input type="number" v-model="account" placeholder="请输入手机号" maxlength="11" />
					</view>
				</view>
				
				<view class="form-item">
					<view class="input-wrapper">
						<text class="input-icon iconfont">&#xe669;</text>
						<input 
							:type="showPassword ? 'text' : 'password'" 
							v-model="password" 
							placeholder="请输入密码" 
							maxlength="20"
						/>
						<text class="password-toggle iconfont" @click="togglePasswordVisibility">
							{{showPassword ? '&#xe66c;' : '&#xe66b;'}}
						</text>
					</view>
				</view>
			</block>
			
			<view class="agreement-box">
				<checkbox-group @change="checkboxChange">
					<label class="agreement-label" @click="toggleAgreement">
						<view class="custom-checkbox" :class="{ checked: isAgreed }">
							<text class="checkmark" v-if="isAgreed">✓</text>
						</view>
						<text class="agreement-text">我已阅读并同意</text>
						<text class="agreement-link" @click.stop="showAgreement">《用户协议》</text>
						<text class="agreement-text">和</text>
						<text class="agreement-link" @click.stop="showPrivacy">《隐私政策》</text>
					</label>
				</checkbox-group>
			</view>
			
			<button class="login-btn" :disabled="!isAgreed" @click="handleLogin">
				{{loginType === 'phone' ? '登录/注册' : '登录'}}
				<text class="btn-icon iconfont">&#xe617;</text>
			</button>
		</view>
		
		<view class="footer-text">
			<text>Copyright © 2024 AI-Leader</text>
		</view>
	</view>
</template>

<script>
import api from '../../utils/api.js';
import userManager from '../../utils/user.js';

export default {
	data() {
		return {
			loginType: 'phone', // phone: 手机号登录, account: 账号密码登录
			// 手机号登录字段
			phone: '',
			code: '',
			counting: false,
			counter: 60,
			timer: null,
			// 账号密码登录字段
			account: '',
			password: '',
			showPassword: false, // 控制密码显示/隐藏
			// 公共字段
			isAgreed: true, // 是否同意协议
			redirectUrl: '/pages/index/index', // 默认跳转页面
			// 开发调试
			devInfo: null
		}
	},
	onLoad(options) {
		// 获取跳转前的页面路径
		if (options.redirect) {
			this.redirectUrl = decodeURIComponent(options.redirect);
		}
		
		// 默认设置为同意协议
		this.isAgreed = true;
	},
	onShow() {
		// 确保每次显示页面时协议状态为已同意
		this.isAgreed = true;
	},
	methods: {
		// 密码显示切换
		togglePasswordVisibility() {
			this.showPassword = !this.showPassword;
		},
		
		// 勾选协议变化处理
		checkboxChange(e) {
			this.isAgreed = e.detail.value.length > 0;
		},
		
		// 点击标签直接切换协议状态
		toggleAgreement() {
			this.isAgreed = !this.isAgreed;
		},
		
		// 显示用户协议
		showAgreement() {
			uni.showModal({
				title: '用户协议',
				content: '感谢您使用我们的应用。请仔细阅读本协议的所有条款。使用我们的服务即表示您同意受本协议约束。',
				confirmText: '我同意',
				success: (res) => {
					if (res.confirm) {
						this.isAgreed = true;
					}
				}
			});
		},
		
		// 显示隐私政策
		showPrivacy() {
			uni.showModal({
				title: '隐私政策',
				content: '我们非常重视您的隐私保护。本隐私政策介绍了我们收集和处理您个人信息的方式，以及您享有的权利。',
				confirmText: '我同意',
				success: (res) => {
					if (res.confirm) {
						this.isAgreed = true;
					}
				}
			});
		},
		
		// 发送验证码
		sendCode() {
			// 检查是否同意协议
			if (!this.isAgreed) {
				uni.showToast({
					title: '请先同意用户协议与隐私政策',
					icon: 'none'
				});
				return;
			}
			
			if (!this.phone || this.phone.length !== 11) {
				uni.showToast({
					title: '请输入正确的手机号',
					icon: 'none'
				});
				return;
			}
			
			// 调用发送验证码接口
			api.user.sendCode(this.phone).then(res => {
				if (res.data && res.data.code === 200) {
					uni.showToast({
						title: '验证码已发送',
						icon: 'success'
					});
					// 开始倒计时
					this.startCounter();
				}
			}).catch(() => {
				// 错误处理已在 request.js 中统一处理
			});
		},
		
		// 倒计时
		startCounter() {
			this.counting = true;
			this.counter = 60;
			this.timer = setInterval(() => {
				if (this.counter > 0) {
					this.counter--;
				} else {
					this.counting = false;
					clearInterval(this.timer);
				}
			}, 1000);
		},
		
		// 处理登录点击
		handleLogin() {
			// 检查是否同意协议
			if (!this.isAgreed) {
				uni.showToast({
					title: '请先同意用户协议与隐私政策',
					icon: 'none'
				});
				return;
			}
			
			// 根据登录类型调用不同的登录方法
			if (this.loginType === 'phone') {
				this.loginByPhone();
			} else {
				this.loginByAccount();
			}
		},
		
		// 手机号验证码登录
		loginByPhone() {
			if (!this.phone || this.phone.length !== 11) {
				uni.showToast({
					title: '请输入正确的手机号',
					icon: 'none'
				});
				return;
			}
			
			if (!this.code) {
				uni.showToast({
					title: '请输入验证码',
					icon: 'none'
				});
				return;
			}
			
			// 显示加载提示
			uni.showLoading({
				title: '登录中...',
				mask: true
			});
			
			// 调用登录接口
			api.user.login(this.phone, this.code, { skipErrorToast: true }).then(res => {
				// 隐藏加载提示
				uni.hideLoading();
				
				if (res.data && res.data.code === 200) {
					// 登录成功，提取并处理数据
					const loginData = this.extractLoginData(res);
					
					if (loginData) {
						this.handleLoginSuccess(loginData, this.phone);
					} else {
						console.error('手机号登录成功但无法提取有效数据', res);
						uni.showToast({
							title: '登录成功，但获取用户信息失败',
							icon: 'none',
							duration: 2000
						});
					}
				} else {
					// 显示错误信息 
					const errorMsg = res.data?.msg || '登录失败，验证码可能已过期';
					
					// 检查是否是验证码相关错误
					if (res.data?.msg && (res.data.msg.includes('验证码') || res.data.msg.includes('code'))) {
						uni.showModal({
							title: '验证码错误',
							content: '您输入的验证码不正确或已过期，请重新获取验证码。',
							confirmText: '重新获取',
							success: (modalRes) => {
								if (modalRes.confirm) {
									// 清空验证码字段
									this.code = '';
									// 如果倒计时已结束，则允许重新获取
									if (!this.counting) {
										this.sendCode();
									}
								}
							}
						});
					} else {
						// 其他错误情况
						uni.showToast({
							title: errorMsg,
							icon: 'none',
							duration: 2000
						});
					}
				}
			}).catch(err => {
				// 隐藏加载提示
				uni.hideLoading();
				
				// 显示错误信息
				uni.showToast({
					title: '登录失败，请稍后再试',
					icon: 'none'
				});
				console.error('登录失败:', err);
			});
		},
		
		// 调试辅助函数
		exposeToDevTools(key, value) {
			// 在开发环境中暴露变量，方便调试
			this.devInfo = this.devInfo || {};
			this.devInfo[key] = value;
			console.log(`[DevInfo] ${key}:`, value);
			
			// 可以在全局作用域中暴露以便控制台访问
			if (typeof window !== 'undefined') {
				window._devInfo = window._devInfo || {};
				window._devInfo[key] = value;
			}
		},
		
		// 判断API返回的数据结构，并提取正确的值
		extractLoginData(res) {
			// 记录原始响应以便调试
			this.exposeToDevTools('loginApiResponse', res);
			
			// 尝试多种可能的数据结构
			let finalData = null;
			
			if (res.data) {
				// 常见的嵌套结构: { data: { code: 200, data: {...} } }
				if (res.data.data) {
					finalData = res.data.data;
				}
				// 直接返回数据结构: { data: { code: 200, access_token: '...' } }
				else if (res.data.access_token || res.data.token) {
					finalData = res.data;
				}
				// 特殊结构: { data: { code: 200, result: {...} } }
				else if (res.data.result) {
					finalData = res.data.result;
				}
			}
			
			// 记录最终提取的数据
			this.exposeToDevTools('extractedLoginData', finalData);
			
			return finalData;
		},
		
		// 账号密码登录
		loginByAccount() {
			console.log('开始账号密码登录流程', { account: this.account, passwordLength: this.password.length });
			
			if (!this.account || this.account.length !== 11) {
				uni.showToast({
					title: '请输入正确的手机号',
					icon: 'none'
				});
				return;
			}
			
			if (!this.password) {
				uni.showToast({
					title: '请输入密码',
					icon: 'none'
				});
				return;
			}
			
			// 密码长度检查
			if (this.password.length < 6 || this.password.length > 20) {
				uni.showToast({
					title: '密码长度应为6-20位',
					icon: 'none'
				});
				return;
			}
			
			// 显示加载提示
			uni.showLoading({
				title: '登录中...',
				mask: true
			});
			
			// 调用账号密码登录接口
			console.log('调用账号密码登录API:', this.account);
			api.user.loginByPassword(this.account, this.password, { skipErrorToast: true })
				.then(res => {
					// 隐藏加载提示
					uni.hideLoading();
					
					console.log('账号密码登录API返回结果:', res.data);
					
					if (res.data && res.data.code === 200) {
						// 登录成功，提取并处理数据
						const loginData = this.extractLoginData(res);
						
						if (loginData) {
							this.handleLoginSuccess(loginData, this.account);
						} else {
							console.error('登录成功但无法提取有效数据', res);
							uni.showToast({
								title: '登录成功，但获取用户信息失败',
								icon: 'none',
								duration: 2000
							});
						}
					} else {
						// 显示错误信息
						const errorMsg = res.data?.msg || '登录失败，请检查账号密码';
						
						// 判断是否是未注册用户
						if (res.data?.msg && (res.data.msg.includes('用户不存在') || res.data.msg.includes('未注册'))) {
							uni.showModal({
								title: '账号未注册',
								content: '该手机号尚未注册，请先使用手机号验证码登录方式进行注册',
								confirmText: '去注册',
								success: (modalRes) => {
									if (modalRes.confirm) {
										// 切换到手机号登录模式
										this.switchLoginType('phone');
										// 自动填写手机号
										this.phone = this.account;
									}
								}
							});
						} 
						// 判断是否是密码错误（同时检查错误码和错误消息）
						else if ((res.data?.code === 500 || res.data?.msg && (res.data.msg.includes('密码错误') || res.data.msg.includes('用户名密码错误')))) {
							uni.showModal({
								title: '用户名或密码错误',
								content: '您输入的账号或密码不正确，请重新输入。如果忘记密码，可使用手机号验证码登录后重设密码。',
								confirmText: '重试',
								cancelText: '忘记密码',
								success: (modalRes) => {
									if (modalRes.cancel) {
										// 切换到手机号登录模式
										this.switchLoginType('phone');
										// 自动填写手机号
										this.phone = this.account;
										// 清空密码字段
										this.password = '';
									} else {
										// 清空密码字段，让用户重新输入
										this.password = '';
										// 聚焦密码输入框
										setTimeout(() => {
											uni.createSelectorQuery()
												.select('input[type="password"]')
												.boundingClientRect()
												.exec(function(res) {
													if (res && res[0]) {
														// 尝试聚焦 - 注意在某些平台可能不支持
														document.querySelector('input[type="password"]')?.focus();
													}
												});
										}, 300);
									}
								}
							});
						} else {
							// 其他错误情况
							uni.showToast({
								title: errorMsg,
								icon: 'none',
								duration: 2000
							});
						}
						console.error('账号密码登录失败:', errorMsg);
					}
				})
				.catch(err => {
					// 隐藏加载提示
					uni.hideLoading();
					
					// 显示错误信息
					uni.showToast({
						title: '登录失败，请稍后再试',
						icon: 'none',
						duration: 2000
					});
					console.error('账号密码登录请求失败:', err);
				});
		},
		
		// 处理登录成功
		handleLoginSuccess(responseData, phone) {
			console.log('登录成功，处理用户信息和令牌', responseData);
			
			// 确保responseData不为空
			if (!responseData) {
				console.error('登录成功但返回数据为空');
				uni.showToast({
					title: '登录成功，但获取用户信息失败',
					icon: 'none',
					duration: 2000
				});
				return;
			}
			
			// 获取access_token，支持不同格式的数据结构
			const token = responseData.access_token || responseData.token || '';
			if (!token) {
				console.error('登录成功但未找到令牌:', responseData);
				uni.showToast({
					title: '登录成功，但获取令牌失败',
					icon: 'none',
					duration: 2000
				});
				return;
			}
			
			// 保存token
			uni.setStorageSync('token', token);
			console.log('令牌已保存');
			
			// 获取userId，支持不同格式的数据结构
			const userId = responseData.userId || responseData.user_id || responseData.id || '';
			if (!userId) {
				console.error('登录成功但未找到用户ID:', responseData);
				uni.showToast({
					title: '登录成功，但获取用户ID失败',
					icon: 'none',
					duration: 2000
				});
				return;
			}
			
			// 保存userId
			uni.setStorageSync('userId', userId);
			console.log('用户ID已保存:', userId);
			
			// 创建完整的用户信息对象
			const userInfo = {
				userId: userId,
				phone: phone,
				// 如果返回的数据中包含其他用户信息，可以添加到这里
				nickname: responseData.nickname || '',
				avatar: responseData.avatar || '',
				// 添加一个登录时间戳
				loginTime: new Date().getTime()
			};
			
			// 使用导入的 userManager 而不是通过 Vue 原型
			userManager.setUserInfo(userInfo);
			console.log('用户信息已保存到用户管理器');
			
			uni.showToast({
				title: '登录成功',
				icon: 'success'
			});
			
			// 登录成功后跳转处理
			setTimeout(() => {
				console.log('准备跳转到:', this.redirectUrl);
				
				// 如果有重定向地址，则使用redirect，否则切换到首页
				if (this.redirectUrl.startsWith('/pages/index/')) {
					// 是tabBar页面，使用switchTab
					uni.switchTab({
						url: this.redirectUrl
					});
				} else {
					// 非tabBar页面，使用redirectTo
					uni.redirectTo({
						url: this.redirectUrl
					});
				}
			}, 1500);
		},
		
		// 切换登录类型
		switchLoginType(type) {
			this.loginType = type;
			// 切换类型时保持协议勾选状态
			this.isAgreed = true;
			
			// 如果是账号密码登录，将手机号自动填入账号字段
			if (type === 'account' && this.phone && !this.account) {
				this.account = this.phone;
			} else if (type === 'phone' && this.account && !this.phone) {
				// 反之亦然
				this.phone = this.account;
			}
		}
	},
	onUnload() {
		// 页面卸载时清除计时器
		if (this.timer) {
			clearInterval(this.timer);
		}
	}
}
</script>

<style>
@font-face {
	font-family: 'iconfont';  
	src: url('https://at.alicdn.com/t/font_3265645_ezl7dp2069.ttf');
}

.login-container {
	padding: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-between;
	height: 100vh;
	position: relative;
	background: linear-gradient(135deg, #f2f8ff 0%, #eef7fe 100%);
	overflow: hidden;
}

/* 背景动效元素 */
.login-bg {
	position: absolute;
	width: 100%;
	height: 100%;
	z-index: 1;
}

.bg-circle {
	position: absolute;
	border-radius: 50%;
	opacity: 0.5;
}

.circle-1 {
	top: -10%;
	right: -10%;
	width: 500rpx;
	height: 500rpx;
	background: linear-gradient(135deg, #4361ee 0%, #3a86ff 100%);
	filter: blur(60rpx);
	animation: float-1 18s ease-in-out infinite, pulse-1 8s ease-in-out infinite;
}

.circle-2 {
	bottom: -5%;
	left: -10%;
	width: 400rpx;
	height: 400rpx;
	background: linear-gradient(135deg, #4cc9f0 0%, #4895ef 100%);
	filter: blur(50rpx);
	animation: float-2 22s ease-in-out infinite, pulse-2 10s ease-in-out infinite;
}

/* 添加一个额外的小圆形，增强动态效果 */
.login-bg::after {
	content: '';
	position: absolute;
	top: 55%;
	right: 10%;
	width: 150rpx;
	height: 150rpx;
	border-radius: 50%;
	background: linear-gradient(135deg, #a3bded 0%, #6991c7 100%);
	opacity: 0.6;
	filter: blur(40rpx);
	z-index: 1;
	animation: float-3 16s ease-in-out infinite, pulse-3 7s ease-in-out infinite;
}

/* 添加第四个元素，更强调左右移动 */
.login-bg::before {
	content: '';
	position: absolute;
	top: 30%;
	left: 5%;
	width: 220rpx;
	height: 220rpx;
	border-radius: 50%;
	background: linear-gradient(135deg, #56CCF2 0%, #2F80ED 100%);
	opacity: 0.5;
	filter: blur(45rpx);
	z-index: 1;
	animation: float-4 20s ease-in-out infinite, pulse-4 9s ease-in-out infinite;
}

/* 添加第五个元素，让效果更明显 */
.login-container::after {
	content: '';
	position: absolute;
	top: 70%;
	right: 25%;
	width: 180rpx;
	height: 180rpx;
	border-radius: 50%;
	background: linear-gradient(135deg, #FF9A8B 0%, #FF6A88 100%);
	opacity: 0.45;
	filter: blur(35rpx);
	z-index: 1;
	animation: float-5 15s ease-in-out infinite, pulse-5 8s ease-in-out infinite;
}

/* 漂浮动画 - 增强水平移动效果 */
@keyframes float-1 {
	0% {
		transform: translateY(0) translateX(0);
	}
	25% {
		transform: translateY(-40rpx) translateX(-120rpx);
	}
	50% {
		transform: translateY(-80rpx) translateX(100rpx);
	}
	75% {
		transform: translateY(-20rpx) translateX(-80rpx);
	}
	100% {
		transform: translateY(0) translateX(0);
	}
}

@keyframes float-2 {
	0% {
		transform: translateY(0) translateX(0);
	}
	33% {
		transform: translateY(60rpx) translateX(-100rpx);
	}
	67% {
		transform: translateY(100rpx) translateX(150rpx);
	}
	100% {
		transform: translateY(0) translateX(0);
	}
}

@keyframes float-3 {
	0% {
		transform: translateY(0) translateX(0) rotate(0);
	}
	20% {
		transform: translateY(-50rpx) translateX(80rpx) rotate(10deg);
	}
	40% {
		transform: translateY(20rpx) translateX(160rpx) rotate(20deg);
	}
	60% {
		transform: translateY(-40rpx) translateX(60rpx) rotate(30deg);
	}
	80% {
		transform: translateY(-20rpx) translateX(-120rpx) rotate(15deg);
	}
	100% {
		transform: translateY(0) translateX(0) rotate(0);
	}
}

@keyframes float-4 {
	0% {
		transform: translateX(0);
	}
	20% {
		transform: translateX(200rpx);
	}
	40% {
		transform: translateX(-100rpx);
	}
	60% {
		transform: translateX(150rpx);
	}
	80% {
		transform: translateX(-80rpx);
	}
	100% {
		transform: translateX(0);
	}
}

@keyframes float-5 {
	0% {
		transform: translateX(0) translateY(0);
	}
	25% {
		transform: translateX(120rpx) translateY(-40rpx);
	}
	50% {
		transform: translateX(-80rpx) translateY(30rpx);
	}
	75% {
		transform: translateX(100rpx) translateY(50rpx);
	}
	100% {
		transform: translateX(0) translateY(0);
	}
}

@keyframes pulse-1 {
	0%, 100% {
		opacity: 0.5;
		width: 500rpx;
		height: 500rpx;
	}
	50% {
		opacity: 0.7;
		width: 580rpx;
		height: 580rpx;
	}
}

@keyframes pulse-2 {
	0%, 100% {
		opacity: 0.5;
		width: 400rpx;
		height: 400rpx;
	}
	50% {
		opacity: 0.8;
		width: 480rpx;
		height: 480rpx;
	}
}

@keyframes pulse-3 {
	0%, 100% {
		opacity: 0.6;
		width: 150rpx;
		height: 150rpx;
	}
	50% {
		opacity: 0.8;
		width: 200rpx;
		height: 200rpx;
	}
}

@keyframes pulse-4 {
	0%, 100% {
		opacity: 0.5;
		width: 220rpx;
		height: 220rpx;
	}
	50% {
		opacity: 0.7;
		width: 280rpx;
		height: 280rpx;
	}
}

@keyframes pulse-5 {
	0%, 100% {
		opacity: 0.45;
		width: 180rpx;
		height: 180rpx;
	}
	50% {
		opacity: 0.65;
		width: 230rpx;
		height: 230rpx;
	}
}

.login-header {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-top: 120rpx;
	z-index: 2;
}

.login-header .logo-image {
	width: 170rpx;
	height: 170rpx;
	border-radius: 20rpx;
	box-shadow: 0 15rpx 30rpx rgba(0, 0, 0, 0.1);
}

.login-header .app-name {
	font-size: 52rpx;
	font-weight: bold;
	color: #333;
	margin-top: 30rpx;
	letter-spacing: 2rpx;
	text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
}

.login-header .app-slogan {
	font-size: 28rpx;
	color: #6a7a8c;
	margin-top: 10rpx;
	letter-spacing: 2rpx;
}

.login-card {
	position: relative;
	width: 650rpx;
	padding: 60rpx 50rpx;
	background-color: rgba(255, 255, 255, 0.9);
	border-radius: 30rpx;
	box-shadow: 0 20rpx 40rpx rgba(0, 0, 0, 0.1);
	backdrop-filter: blur(10rpx);
	z-index: 2;
}

.login-tabs {
	display: flex;
	margin-bottom: 50rpx;
	border-bottom: 1px solid #eef1f6;
}

.tab-item {
	flex: 1;
	text-align: center;
	padding: 25rpx 0;
	font-size: 32rpx;
	color: #6a7a8c;
	position: relative;
	transition: all 0.3s;
}

.tab-item.active {
	color: #3a86ff;
	font-weight: bold;
}

.tab-item.active::after {
	content: '';
	position: absolute;
	bottom: -2rpx;
	left: 50%;
	transform: translateX(-50%);
	width: 70rpx;
	height: 6rpx;
	background-color: #3a86ff;
	border-radius: 3rpx;
	transition: all 0.3s;
}

.form-item {
	margin-bottom: 35rpx;
}

.input-wrapper {
	display: flex;
	align-items: center;
	height: 110rpx;
	background-color: #f7f9fe;
	border-radius: 55rpx;
	padding: 0 35rpx;
	box-shadow: inset 0 2rpx 5rpx rgba(0, 0, 0, 0.03);
	transition: all 0.3s;
}

.input-wrapper:focus-within {
	box-shadow: inset 0 2rpx 5rpx rgba(0, 0, 0, 0.03), 0 0 0 2rpx rgba(58, 134, 255, 0.2);
}

.input-icon {
	font-size: 40rpx;
	color: #3a86ff;
	margin-right: 20rpx;
}

.iconfont {
	font-family: 'iconfont';
}

input {
	flex: 1;
	height: 100%;
	font-size: 32rpx;
	color: #333;
	background-color: transparent;
}

.code-wrapper {
	position: relative;
	padding-right: 15rpx;
}

.code-btn {
	height: 80rpx;
	line-height: 80rpx;
	background: linear-gradient(135deg, #3a86ff 0%, #4361ee 100%);
	color: #fff;
	font-size: 26rpx;
	border-radius: 40rpx;
	padding: 0 35rpx;
	font-weight: 500;
	box-shadow: 0 6rpx 12rpx rgba(58, 134, 255, 0.25);
	transition: all 0.3s;
}

.code-btn:active {
	transform: translateY(2rpx);
	box-shadow: 0 3rpx 6rpx rgba(58, 134, 255, 0.25);
}

.code-btn[disabled] {
	background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
	box-shadow: none;
	opacity: 0.7;
}

.password-toggle {
	font-size: 40rpx;
	color: #6a7a8c;
	padding: 0 10rpx;
}

.agreement-box {
	margin: 40rpx 0 50rpx;
}

.agreement-label {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
}

.custom-checkbox {
	width: 36rpx;
	height: 36rpx;
	border-radius: 50%;
	border: 2rpx solid #3a86ff;
	margin-right: 15rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.custom-checkbox.checked {
	background-color: #3a86ff;
}

.checkmark {
	color: #fff;
	font-size: 24rpx;
	line-height: 1;
}

.agreement-text {
	font-size: 26rpx;
	color: #6a7a8c;
}

.agreement-link {
	font-size: 26rpx;
	color: #3a86ff;
	margin: 0 5rpx;
}

.login-btn {
	width: 100%;
	height: 110rpx;
	line-height: 110rpx;
	background: linear-gradient(135deg, #3a86ff 0%, #4361ee 100%);
	color: #fff;
	font-size: 34rpx;
	font-weight: bold;
	border-radius: 55rpx;
	box-shadow: 0 10rpx 25rpx rgba(58, 134, 255, 0.35);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s;
	position: relative;
	overflow: hidden;
}

.login-btn::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
	transition: all 0.6s;
}

.login-btn:active {
	transform: scale(0.98);
	box-shadow: 0 5rpx 15rpx rgba(58, 134, 255, 0.35);
}

.login-btn:active::before {
	left: 100%;
}

.login-btn[disabled] {
	background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
	box-shadow: none;
	opacity: 0.7;
}

.btn-icon {
	margin-left: 10rpx;
	font-size: 28rpx;
}

.footer-text {
	position: relative;
	font-size: 26rpx;
	color: #6a7a8c;
	margin-bottom: 50rpx;
	z-index: 2;
}
</style> 